package com.zfsmart;

import cn.hutool.core.date.CalendarUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.http.HttpUtil;
import com.zfsmart.bean.DimDateBean;
import com.zfsmart.helper.DimDateHelper;

import javax.xml.crypto.Data;
import java.io.File;
import java.time.LocalDateTime;
import java.time.Year;
import java.util.ArrayList;
import java.util.List;

/**
 * @author xuetieqi
 * @date 2023/2/18 11:26 AM
 **/
public class Application {
    public static final String filePath = "/Users/xuetieqi/Desktop/dim_date.txt";
    public static final int year = 2023;

    public static void main(String[] args) {
        //当年的假期
        //准备数据
        DimDateHelper helper = new DimDateHelper();
        LocalDateTime item = LocalDateTime.of(year, 1, 1, 0, 0);
        List<String> text = new ArrayList<>();
        LocalDateTime limit = item.plusYears(1);
        while (item.isBefore(limit)) {
            DimDateBean trans = helper.trans(LocalDateTimeUtil.format(item, "yyyy-MM-dd"));
            text.add(trans.toString());
            item = item.plusDays(1);
        }

        //写入文件
        FileUtil.appendLines(text, new File(filePath), "utf8");
    }
}
